$(function(){
	reLoad();
	$("#nowMai").click(function(){
		if(userid == null || userid == ''){
			orginalAlert("请先登录")
			window.location.href = '/LianniuWeb/login.do'
			return;
		}
		dealTo(toOrderPage);
	});
	getProductDetail(localStorage.getItem('skuId'));
});
/*
 * 商品详细信息
 */
var getProductDetail = function(skuId){
	$.ajax({
		url:server_url+"buyer/product/rest/getProductDetail.do?id="+skuId,
		type:'get',
		data:{ran:Math.random()},
		ansyc:false,
		error:function(){alert(contants.systemError)},
		success:function(msg){
			var data = msg.data;
			var datas = [];
			datas.push(data);
			localStorage.setItem("products",JSON.stringify(datas));
			dealProductDetail(data);
		}
	});
}
var dealProductDetail = function(data){
	$('#intrName').text(data.productName+' '+data.specName);
	$('#overPlusNum').text("库存："+data.overPlusNum+"头");
	$('#location').text("货源地:"+data.areaName);
	$("#remark").text("备注：" + data.remark);
	$('#price').text(data.price+'元/头');
	$("#id").text("编号："+data.id);
	$("#specName").text("类别："+data.specName);
	$('.pic1').attr('src',data.picturePath1);
	if(data.picturePath2 != null){
		$('.pic2').attr('src',data.picturePath2);
	}else{
		$('.pic2').attr('src',data.picturePath1);
	}
	if(data.picturePath2 != null && data.picturePath3 != null){
		$('.pic3').attr('src',data.picturePath3);
	}else if(data.picturePath2 == null){
		$('.pic3').attr('src',data.picturePath1);
	}else if(data.picturePath2 !=null && data.picturePath3 == null){
		$('.pic3').attr('src',data.picturePath2);
	}

	$("#callStaff").attr("href","tel:4008637797");
}
//立即购买，去下单页面
var dealTo = function(fn){
	fn();
}
var toOrderPage = function(){
	window.location.href=server_url+"buyer/product/addOrder.do";
}
